package com.jaymin.flink.sink;

import org.apache.flink.api.java.tuple.Tuple2;
import org.apache.flink.api.java.tuple.Tuple3;
import org.apache.flink.streaming.connectors.redis.common.mapper.RedisCommand;
import org.apache.flink.streaming.connectors.redis.common.mapper.RedisCommandDescription;
import org.apache.flink.streaming.connectors.redis.common.mapper.RedisMapper;

/**
 * @author jaymin
 * @since 2024/4/5 23:55
 */
public class RedisExampleMapper implements RedisMapper<Tuple2<Integer, Integer>> {


    @Override
    public RedisCommandDescription getCommandDescription() {
        return new RedisCommandDescription(RedisCommand.HSET, "os_user-nu-cnt:20301002");
    }

    @Override
    public String getKeyFromData(Tuple2<Integer, Integer> stringIntegerIntegerTuple3) {
        return stringIntegerIntegerTuple3.f0 + "";
    }

    @Override
    public String getValueFromData(Tuple2<Integer, Integer> stringIntegerIntegerTuple3) {
        return stringIntegerIntegerTuple3.f1 + "";
    }
}
